package club.justwill.single.persistence.document;

import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * Created by xiangnan on 16-1-14.
 */
@Document(collection = "session_data")
public class SessionData extends MongoDocument {

    @Field("cookie_id")
    @Indexed(name = "session_data_cookie_id")
    private String cookieId;

    @Field("user_id")
    @Indexed(name = "session_data_user_id")
    private Long userId;

    @Field("user_type")
    private Integer userType;

    @Field("verification_expiry")
    @Indexed(name = "session_data_verification_expiry", direction = IndexDirection.ASCENDING)
    private Date verificationExpiry;

    @Field("fail_attempt")
    private int failedAttempt;

    @Field("session_id")
    private String SessionId;

    public String getCookieId() {
        return cookieId;
    }

    public void setCookieId(String cookieId) {
        this.cookieId = cookieId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        if(userId == null) {
            this.userId = 0L;
        } else {
            this.userId = userId;
        }

    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }

    public Date getVerificationExpiry() {
        return verificationExpiry;
    }

    public void setVerificationExpiry(Date verificationExpiry) {
        this.verificationExpiry = verificationExpiry;
    }

    public int getFailedAttempt() {
        return failedAttempt;
    }

    public void setFailedAttempt(int failedAttempt) {
        this.failedAttempt = failedAttempt;
    }

    public String getSessionId() {
        return SessionId;
    }

    public void setSessionId(String sessionId) {
        SessionId = sessionId;
    }
}
